#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#define N 100010
int arr[N];
int quick_sort(int l, int r,int k)
{
	if (l >= r) return arr[l];
	int i = l - 1, j = r + 1, mid = (r + l) >> 1;
	int q = arr[mid];
	while (i < j)
	{
		do i++; while (arr[i] < q);
		do j--; while (arr[j] > q);
		if(i<j)
		{
			int tmp = arr[i];
			arr[i] = arr[j];
			arr[j] = tmp;
		}
	}
	int sl = j - l + 1;
	if (k <= sl) quick_sort(l, j, k);
	else quick_sort(j + 1, r, k-sl);
}
int main()
{
	int n, x;
	scanf("%d%d", &n, &x);
	int i = 0;
	for (i = 1; i <=n; i++)
		scanf("%d", &arr[i]);
	int ret = quick_sort(1, n, x);
	printf("%d", ret);
	return 0;
}